srcPart, tgtPart, tocode, todecode = input(), input(), input(), input()
print ("".join((dict(((srcPart[i],tgtPart[i]) for i in range(len(srcPart))))[i] for i in tocode)) + '\n' + "".join((dict(((tgtPart[i], srcPart[i]) for i in range(len(srcPart))))[i] for i in todecode)))

